
import Snowflake from './snowflake'

const random = Math.random
class Heart extends Snowflake {
  constructor ({x = 0, y = 0, minSize = 10, maxSize = 15, size, speed = 1} = {}) {
    super({minSize, maxSize, x, y, size, speed})
    this.color = `rgb(255, 140, 0)`
  }
  render (ctx) {
    this.fall()
    if (this.outOfBounds()) return false

    ctx.save()
    ctx.beginPath()
    ctx.fillStyle = this.color
    ctx.moveTo(this.x + 0.5 * this.size, this.y + 0.3 * this.size)
    ctx.bezierCurveTo(this.x + 0.1 * this.size, this.y, this.x,
      this.y + 0.6 * this.size, this.x + 0.5 * this.size, this.y + 0.9 * this.size)
    ctx.bezierCurveTo(this.x + 1 * this.size, this.y + 0.6 * this.size, this.x + 0.9 * this.size, this.y,
      this.x + 0.5 * this.size, this.y + 0.3 * this.size)
    ctx.closePath()
    ctx.fill()
    ctx.restore()

    return true
  }
}

export default Heart
